<?php
namespace Admin\Controller;
use Think\Controller;
/**
 * 客户买卖操作方法控制器
 * Class Customermall
 * @package app\admin\controller
 */
class CustomermallactionController extends BaseController
{

    public $no_login_action = array();
    public $customerInfo = array();

    /**
     * 自动执行函数
     */
    public function _initialize()
    {
        parent::_initialize();

        //下面开始默认的判断
        if (!$this->data['company_id']||!$this->data['first_customer_id']) {
            $this->errorjsonReturn('参数错误');
        }
        
        //下面获取客户的信息
        $this->customerInfo = M('first_customer')->where(array('id'=>$this->data['first_customer_id']))->find();
        if (!$this->customerInfo) {
            $this->errorjsonReturn('无数据');
        }
    }

    /**
     * 写入推送日志
     */
    public function addLog($api_ok,$api_error_msg,$api_back)
    {
        //开始写库
        $add=array();
        $add['first_customer_id'] = $this->data['first_customer_id'];
        $add['mall_company_id'] = $this->data['company_id'];
        $add['is_ok'] = $api_ok ? 1:2;
        $add['error_msg'] = $api_error_msg;
        $add['api_data'] = $api_back;
        M('mall_sale_log')->add($add);
    }

    /**
     * 除去数组中的空值和签名模式
     */
    private function para_filter($params) 
    {
        $para = array();
        while (list ($key, $val) = each ($params)) {
            if($key == "sign" || $val == ""){
                continue;
            }else{
                $para[$key] = $params[$key];
            }
        }
        return $para;
    }
}